package com.cdd.eduservice.controller;


import com.cdd.commonutils.R;
import com.cdd.eduservice.entity.subject.OneSubject;
import com.cdd.eduservice.service.IEduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author cdd
 * @since 2021-02-01
 */
@RestController
@RequestMapping("/eduservice/edu-subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private IEduSubjectService iEduSubjectService;

    //添加课程分类
    //获取上传过来的文件，把文件内容读取出来
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){


        iEduSubjectService.saveSubject(file, iEduSubjectService);
        return R.ok();
    }

    // 课程分类（树形）
    @GetMapping("getAllSubject")
    public R getAllSubject(){
//        List<OneSubject> list = iEduSubjectService.getAllOneTwoSubject();
        List<OneSubject> list = iEduSubjectService.Recursion();
        return R.ok().data("list",list);
    }
}

